package clids.ex2.orders;

import java.io.File;
import java.util.Comparator;
import java.util.Date;

public class OrderModComparator implements Comparator<String> {
	// implementation of lat-modified comparator;
	@SuppressWarnings("deprecation")
	public int compare(String o1, String o2) {
		File f1 = new File(o1);
		File f2 = new File(o2);
		long lastMod1 = f1.lastModified();
		long lastMod2 = f2.lastModified();
		Date d1 = new Date(lastMod1);
		Date d2 = new Date(lastMod2);
		d1.setSeconds(0);
		d2.setSeconds(0);
		d2.setMinutes(0);
		d1.setMinutes(0);

		if (d1.compareTo(d2) == 0) {
			return o1.compareTo(o2);
		}
		return d1.compareTo(d2);

	}
}
